import React, { Component } from 'react'
import { Modal,Input, message,Form, Select } from 'antd'
import axios from 'axios'


const { Option } = Select;
export default class Updata extends Component {
    state={
        "id":this.props.list.id,
        "memberName": this.props.list.memberName,
        "memberPass": this.props.list.memberPass,
        "role": this.props.list.role,
    }
    getVal=(e)=>{
        this.setState({
            [e.target.name]:e.target.value
        })
    }
    update=()=>{
        console.log(this.state.id)
        console.log(this.state.memberName)
        console.log(this.state.memberPass)
        console.log(this.state.role)
        axios.post("/api/payment/admin/update",{
            "id":this.state.id,
            "memberName": this.state.memberName,
            "memberPass": this.state.memberPass,
            "role": this.state.role
        }).then(res=>{
            console.log(res)
            if(res.data.code===200){
                message.success(res.data.msg,1,()=>{
                    this.props.closeUpdate()
                })
            }
        })
    }
  render() {
      const {list,updateVisible,closeUpdate} = this.props
    return (
      <div>
          <Modal title="修改信息" visible={updateVisible} okText={"确定"} cancelText={"取消"} onCancel={closeUpdate} onOk={this.update}>
              <Input style={{height: "50px",marginBottom:" 20px",borderRadius: "5px"}} type="text" name="memberName" placeholder={list.memberName} onChange={this.getVal} ></Input>
              <Input placeholder="******" style={{height: "50px",marginBottom:" 20px",borderRadius: "5px"}} type="password" name="memberPass" onChange={this.getVal}></Input>
              <Form>
              <Form.Item style={{width:"200px",borderRadius: "5px"}} name="gender" rules={[{required: true,},]}>
                <Select placeholder={this.props.list.role===2?"超级管理员":this.props.list.role===1?"管理员":"用户"} onChange={this.onGenderChange}>
                    <Option value="user">用户</Option>
                    <Option value="admin">管理员</Option>
                    <Option value="superadmin">超级管理员</Option>
                </Select>
            </Form.Item>
              </Form>
          </Modal>
      </div>
    )
  }
}
